﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ArtOfTest.WebAii.Controls.HtmlControls;
using SM2Utilities;
using SM2Profile;

namespace SM2SetupSearch
{
    public class SearchCommonActions
    {
        public static Boolean wasExisted(string strProfile, string strKeyword)
        {
            /*  Load home.aspx is the Profiles Page
             *  Load profile to be used for adding new search
             *  Load Search-Setup page which is advanced_search_keywords.aspx
             */
            if (!TableOfSearchActions.is_advanced_search_keywords_loaded())
            {
                CommonLoader.load("home.aspx");
                ProfileActions.loadProfile(strProfile);
                CommonLoader.load("advanced_search_keywords.aspx");
            }

            //Check to see if the search was created or not
            string strCheckingID = TableOfSearchActions.GetIDKeyword(strKeyword);
            if (strCheckingID.Equals(""))
                return false;
            else
                return true;

        }

        public static void ClikOnButton(string strBtnName)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv cphPageContent_pnlSearchSetup = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("cphPageContent_pnlSearchSetup");
            IList<HtmlInputSubmit> iListSubmit = cphPageContent_pnlSearchSetup.Find.AllByAttributes<HtmlInputSubmit>();

            for (int i = 0; i < iListSubmit.Count; i++)
            {
                HtmlInputSubmit btn = iListSubmit[i];
                string strLabelButton = btn.Value;
                if (strLabelButton != null && strLabelButton.Equals(strBtnName))
                {
                    SM2Input.Tradition.ClickButton(btn);
                    break;
                }
            }
        }

        public static void ConfirmDelete(Boolean blYesOrNo, Boolean blDeleteAllResults)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv cphPageContent_pnlMpeDeleteConfirmation = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("cphPageContent_pnlMpeDeleteConfirmation");

            if (!blYesOrNo)
            {
                HtmlInputSubmit cphPageContent_btnCancel = cphPageContent_pnlMpeDeleteConfirmation.Find.ById<HtmlInputSubmit>("cphPageContent_btnCancel");
                SM2Input.Tradition.ClickButton(cphPageContent_btnCancel);
            }
            else
            {
                HtmlInputCheckBox cphPageContent_cbDeleteRelatedResults = cphPageContent_pnlMpeDeleteConfirmation.Find.ById<HtmlInputCheckBox>("cphPageContent_cbDeleteRelatedResults");
                if (blDeleteAllResults)
                {                    
                    cphPageContent_cbDeleteRelatedResults.Checked = true;
                }
                else
                {
                    cphPageContent_cbDeleteRelatedResults.Checked = false;
                }
                HtmlInputSubmit cphPageContent_btnDeleteSearch = cphPageContent_pnlMpeDeleteConfirmation.Find.ById<HtmlInputSubmit>("cphPageContent_btnDeleteSearch");
                SM2Input.Tradition.ClickButton(cphPageContent_btnDeleteSearch);

                //Close
                HtmlDiv pnlMpeEndMessage = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlMpeEndMessage");
                while (!pnlMpeEndMessage.IsVisible())
                {
                    Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
                    pnlMpeEndMessage = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlMpeEndMessage");
                }
                HtmlInputSubmit btnCloseMessage = pnlMpeEndMessage.Find.ById<HtmlInputSubmit>("btnCloseMessage");
                SM2Input.Tradition.ClickButton(btnCloseMessage);
                
            }
        }

        public static void CancelInSearchSettingPage()
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlInputSubmit search_cancel_button = search_setup.Find.ById<HtmlInputSubmit>("search-cancel-button");
            SM2Input.Tradition.ClickButton(search_cancel_button);
        }

        public static void SaveInSearchSettingPage()
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");

            HtmlInputSubmit search_save_button = search_setup.Find.ById<HtmlInputSubmit>("search-save-button");
            SM2Input.Tradition.ClickButton(search_save_button);

            Utilities.GlobalObject.MANAGER.ActiveBrowser.WaitUntilReady();
            System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_TIMEOUT_MILISECOND);
        }

        public static void ChangeTypeOfSeachCreation(string strType)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-setup");
            HtmlForm create_search_form = search_setup.Find.ById<HtmlForm>("create-search-form");

            HtmlDiv search_options = search_wizard_panel.Find.ById<HtmlDiv>("search-options");
            IList<HtmlAnchor> iListSubmit = search_options.Find.AllByAttributes<HtmlAnchor>();
            string strCurrentStatus = "";
            switch (strType)
            {
                case SetupSearch.MANUALENTRY:
                    for (int i = 0; i < iListSubmit.Count; i++)
                    {
                        HtmlAnchor btn = iListSubmit[i];
                        string strLabelButton = btn.GetValue("href", "blank");
                        strCurrentStatus = btn.GetValue("disabled", "enable");
                        if (strLabelButton != null && strLabelButton.Contains("#tabs-advanced-entry"))
                        {
                            if (!strCurrentStatus.Equals("disable"))
                            {
                                SM2Input.Tradition.ClickAnchor(btn);
                                break;
                            }
                        }
                    }
                    break;

                case SetupSearch.QUERYBUILDER:
                    for (int i = 0; i < iListSubmit.Count; i++)
                    {
                        HtmlAnchor btn = iListSubmit[i];
                        string strLabelButton = btn.GetValue("href", "blank");
                        strCurrentStatus = btn.GetValue("disabled", "enable");
                        if (strLabelButton != null && strLabelButton.Contains("#tabs-query-builder"))
                        {
                            if (!strCurrentStatus.Equals("disable"))
                            {
                                SM2Input.Tradition.ClickAnchor(btn);
                                break;
                            }
                        }
                    }
                    break;

                case SetupSearch.BULKUPLOAD:
                    for (int i = 0; i < iListSubmit.Count; i++)
                    {
                        HtmlAnchor btn = iListSubmit[i];
                        string strLabelButton = btn.GetValue("href", "blank");
                        strCurrentStatus = btn.GetValue("disabled", "enable");
                        if (strLabelButton != null && strLabelButton.Contains("#tabs-bulk-upload"))
                        {
                            if (!strCurrentStatus.Equals("disable"))
                            {
                                SM2Input.Tradition.ClickAnchor(btn);
                                break;
                            }
                        }
                    }
                    break;

                default:
                    break;
            }
        }

        #region Country

        public static void FilterByCountrySelectAll()
        {
            //Input
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");
            
            HtmlInputRadioButton AllCountriesTrue = search_filter_results.Find.ById<HtmlInputRadioButton>("AllCountriesTrue");
            AllCountriesTrue.Checked = true;
            AllCountriesTrue.Click();
        }

        public static void FilterByCountryInclude(string strCountry)
        {
            //Input
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");

            HtmlInputRadioButton AllCountriesFalse = search_filter_results.Find.ById<HtmlInputRadioButton>("AllCountriesFalse");
            AllCountriesFalse.Checked = true;
            AllCountriesFalse.Click();

            HtmlInputRadioButton IncludeSelectedCountriesTrue = search_filter_results.Find.ById<HtmlInputRadioButton>("IncludeSelectedCountriesTrue");
            IncludeSelectedCountriesTrue.Checked = true;
            IncludeSelectedCountriesTrue.Click();

            HtmlDiv countries_select_box = search_filter_results.Find.ById<HtmlDiv>("countries-select-box");
            string strID = Repository.TestDataUtil.getCountryCode(strCountry);
            HtmlInputCheckBox countrycheckbox = countries_select_box.Find.ById<HtmlInputCheckBox>("country-" + strID);
            SM2Input.Tradition.SelectCheckbox(countrycheckbox);
        }

        public static void FilterByCountryExclude(string strCountry)
        {
            //Input
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");

            HtmlInputRadioButton AllCountriesFalse = search_filter_results.Find.ById<HtmlInputRadioButton>("AllCountriesFalse");
            AllCountriesFalse.Checked = true;
            AllCountriesFalse.Click();

            HtmlInputRadioButton IncludeSelectedCountriesFalse = search_filter_results.Find.ById<HtmlInputRadioButton>("IncludeSelectedCountriesFalse");
            IncludeSelectedCountriesFalse.Checked = true;
            IncludeSelectedCountriesFalse.Click();

            HtmlDiv countries_select_box = search_filter_results.Find.ById<HtmlDiv>("countries-select-box");
            string strID = Repository.TestDataUtil.getCountryCode(strCountry);
            HtmlInputCheckBox countrycheckbox = countries_select_box.Find.ById<HtmlInputCheckBox>("country-" + strID);
            SM2Input.Tradition.SelectCheckbox(countrycheckbox);
        }

        #endregion

        #region Languages

        public static void FilterByLanguagesSelectAll()
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");

            HtmlInputRadioButton AllLanguagesTrue = search_filter_results.Find.ById<HtmlInputRadioButton>("AllLanguagesTrue");
            AllLanguagesTrue.Checked = true;
            AllLanguagesTrue.Click();
        }

        public static void FilterByLanguageInclude(string strLanguage)
        {
            //Input
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");

            HtmlInputRadioButton AllLanguagesFalse = search_filter_results.Find.ById<HtmlInputRadioButton>("AllLanguagesFalse");
            AllLanguagesFalse.Checked = true;
            AllLanguagesFalse.Click();

            HtmlInputRadioButton IncludeSelectedLanguagesTrue = search_filter_results.Find.ById<HtmlInputRadioButton>("IncludeSelectedLanguagesTrue");
            IncludeSelectedLanguagesTrue.Checked = true;
            IncludeSelectedLanguagesTrue.Click();

            HtmlDiv languages_select_box = search_filter_results.Find.ById<HtmlDiv>("languages-select-box");

            string strID = Repository.TestDataUtil.getLanguagesCode(strLanguage);
            HtmlInputCheckBox languagecheckbox = languages_select_box.Find.ById<HtmlInputCheckBox>("language-" + strID);
            SM2Input.Tradition.SelectCheckbox(languagecheckbox);
        }

        public static void FilterByLanguageExclude(string strLanguage)
        {
            //Input
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");

            HtmlInputRadioButton AllLanguagesFalse = search_filter_results.Find.ById<HtmlInputRadioButton>("AllLanguagesFalse");
            AllLanguagesFalse.Checked = true;
            AllLanguagesFalse.Click();

            HtmlInputRadioButton IncludeSelectedLanguagesFalse = search_filter_results.Find.ById<HtmlInputRadioButton>("IncludeSelectedLanguagesFalse");
            IncludeSelectedLanguagesFalse.Checked = true;
            IncludeSelectedLanguagesFalse.Click();

            HtmlDiv languages_select_box = search_filter_results.Find.ById<HtmlDiv>("languages-select-box");

            string strID = Repository.TestDataUtil.getLanguagesCode(strLanguage);
            HtmlInputCheckBox language_checkbox = search_filter_results.Find.ById<HtmlInputCheckBox>("language-" + strID);
            SM2Input.Tradition.SelectCheckbox(language_checkbox);
        }

        #endregion

        public static void FilterByDateRange(string strFromDate, string strToDate)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");
            
            HtmlDiv selected_date_range_content = search_filter_results.Find.ById<HtmlDiv>("selected-date-range-content");
            HtmlInputText FromDate = search_filter_results.Find.ById<HtmlInputText>("FromDate");
            HtmlInputText ToDate = search_filter_results.Find.ById<HtmlInputText>("ToDate");
            FromDate.Text = "";
            SM2Input.Tradition.TypeTextIntoTextField(FromDate, strFromDate);
            SM2Input.Tradition.TypeTextIntoTextField(ToDate, strToDate);
        }

        public static void FilterByFullHistorical()
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");

            HtmlInputRadioButton IncludeAllDatesTrue = search_filter_results.Find.ById<HtmlInputRadioButton>("IncludeAllDatesTrue");
            IncludeAllDatesTrue.Checked = true;
            IncludeAllDatesTrue.Click();
        }

        public static void AdvancedExcludes(string strExcludedWord)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlDiv search_filter_results = search_common_setup.Find.ById<HtmlDiv>("search-filter-results");
            HtmlInputText NewExcludeWord = search_filter_results.Find.ById<HtmlInputText>("NewExcludeWord");
            SM2Input.Tradition.TypeTextIntoTextField(NewExcludeWord, strExcludedWord);
            HtmlInputSubmit add_filter_word_button = search_filter_results.Find.ById<HtmlInputSubmit>("add-filter-word-button");
            SM2Input.Tradition.ClickButton(add_filter_word_button);
        }

        public static void OrganizeResults(string strTypeOfSearch, string strCategory)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");
            HtmlDiv search_organize_results = search_common_setup.Find.ById<HtmlDiv>("search-organize-results");


            HtmlSelect SearchTypeId = search_organize_results.Find.ById<HtmlSelect>("SearchTypeId");
            SM2Input.Tradition.SelectItemSelectList(SearchTypeId, strTypeOfSearch);

            HtmlInputText add_category_textbox = search_organize_results.Find.ById<HtmlInputText>("add-category-textbox");
            SM2Input.Tradition.TypeTextIntoTextField(add_category_textbox, strCategory);
        
            HtmlInputSubmit add_category_button = search_organize_results.Find.ById<HtmlInputSubmit>("add-category-button");
            SM2Input.Tradition.ClickButton(add_category_button);        
    }

        public static void FilterResultsForSpam(Boolean blFilterForSpam)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlInputCheckBox FilterSpam = search_common_setup.Find.ById<HtmlInputCheckBox>("FilterSpam");
            FilterSpam.Checked = blFilterForSpam;
        }

        public static void EnabledKeywordUponCreating(Boolean blEnabledKeywordUponCreating)
        {
            Utilities.GlobalObject.MANAGER.ActiveBrowser.RefreshDomTree();
            HtmlDiv pnlContent = Utilities.GlobalObject.MANAGER.ActiveBrowser.Find.ById<HtmlDiv>("pnlContent");
            HtmlDiv cphPageContent_mSearchWizard = pnlContent.Find.ById<HtmlDiv>("cphPageContent_mSearchWizard");
            HtmlDiv search_wizard_panel = cphPageContent_mSearchWizard.Find.ById<HtmlDiv>("search-wizard-panel");
            HtmlDiv search_common_setup = search_wizard_panel.Find.ById<HtmlDiv>("search-common-setup");

            HtmlInputCheckBox Enabled = search_common_setup.Find.ById<HtmlInputCheckBox>("Enabled");
            Enabled.Checked = blEnabledKeywordUponCreating;
        }
    }
}
